home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / pdcurs21 / portable / copywin.c < prev    next >
C/C++ Source or Header  |  1993-06-18  |  3KB  |  88 lines

  1. #define    CURSES_LIBRARY    1
  2. #include <curses.h>
  3. #undef    copywin
  4.  
  5. #ifdef PDCDEBUG
  6. char *rcsid_copywin = "$Header: C:\CURSES\portable\RCS\copywin.c 2.1 1993/06/18 20:19:07 MH Rel MH $";
  7. #endif
  8.  
  9.  
  10.  
  11.  
  12. /*man-start*********************************************************************
  13.  
  14.   copywin()    - Overlay/overwrite a part of a window on top of another.
  15.  
  16.   PDCurses Description:
  17.      This routine is similar to overwrite() and overlay() but copywin()
  18.      does not require that the two windows overlap.
  19.  
  20.      The arguments src_tc and src_tr specify the top left corner of the
  21.      region to be copied to the destination window.
  22.      The arguments dst_tc,dst_tr,dst_br,dst_bc specify the region within
  23.      the destination window to where the copy is made.
  24.  
  25.      The argument overlay, if TRUE, indicates that the copy is done
  26.      non-destructively (as in overlay()). Blanks in the source window
  27.      are not copied to the destination window. When overlay is FALSE,
  28.      (as in overwrit()), the copy is destructive; blanks are copied
  29.      to the destination window.
  30.  
  31.   PDCurses Errors:
  32.      It is an error to pass a NULL window pointer.
  33.  
  34.   Portability:
  35.      PDCurses    int    copywin( WINDOW* src_w, WINDOW* dst_w, int src_tc,
  36.              int src_tc, int dst_tr, int dst_tc, int dst_br, int dst_bc,
  37.              bool overlay);
  38.      X/Open Dec '88
  39.      SYS V Curses    int    copywin( WINDOW* src_w, WINDOW* dst_w, int src_tr,
  40.              int src_tc, int dst_tr, int dst_tc, int dst_br, int dst_bc,
  41.              bool overlay);
  42.  
  43. **man-end**********************************************************************/
  44.  
  45. int    copywin(WINDOW *src_w, WINDOW *dst_w, int src_tr,
  46.              int src_tc, int dst_tr, int dst_tc, int dst_br, int dst_bc,
  47.              bool overlay)
  48. {
  49.     int    src_start_x = src_tc;
  50.     int    src_start_y = src_tr;
  51.     int    dst_start_x = dst_tc;
  52.     int    dst_start_y = dst_tr;
  53.     int    src_end_x;
  54.     int    src_end_y;
  55.     int    dst_end_x;
  56.     int    dst_end_y;
  57.     int    src_rows,src_cols;
  58.     int    dst_rows,dst_cols;
  59.     int    min_rows,min_cols;
  60.     int    max_rows,max_cols;
  61.     int    rc;
  62.  
  63. #ifdef PDCDEBUG
  64.     if (trace_on) PDC_debug("copywin() - called\n");
  65. #endif
  66.  
  67.     if (src_w == (WINDOW *)NULL)    return( ERR );
  68.     if (dst_w == (WINDOW *)NULL)    return( ERR );
  69.  
  70.     src_rows = src_w->_maxy - src_tr;
  71.     src_cols = src_w->_maxx - src_tc;
  72.     dst_rows = dst_br - dst_tr;
  73.     dst_cols = dst_bc - dst_tc;
  74.  
  75.     min_rows = min(src_rows,dst_rows);
  76.     min_cols = min(src_cols,dst_cols);
  77.  
  78.     src_end_y = src_tr + min_rows;
  79.     src_end_x = src_tc + min_cols;
  80.     dst_end_y = dst_tr + min_rows;
  81.     dst_end_x = dst_tc + min_cols;
  82.  
  83.     rc = PDC_copy_win(src_w,dst_w,src_start_y,src_start_x,src_end_y,src_end_x,
  84.         dst_start_y,dst_start_x,dst_end_y,dst_end_x,overlay);
  85.  
  86.     return( rc );
  87. }
  88.